home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ASMLIB30.ARJ / TEXTDEMO.ASM < prev    next >
Assembly Source File  |  1992-06-14  |  3KB  |  188 lines

  1. ; TEXTDEMO.ASM - Demonstration program for ASMLIB
  2. ;  Programmer: Doug Herr
  3. ;  date: 6/10/1992
  4.  
  5.  
  6. include    asm.inc
  7.  
  8. public    textdemo
  9. extrn    wframe:proc, getkey:proc, wfill:proc
  10. extrn    wsave:proc, wsize:proc, dosalloc:proc
  11. extrn    wrestore:proc, tprint:proc
  12. extrn    hscroll:proc, vscroll:proc
  13. extrn    ansicolor:proc
  14. extrn    crtinfo:proc
  15. extrn    tcopy:proc, usetpage:proc
  16.  
  17. .data
  18. wseg        dw ?
  19. r0        dw 0
  20. c0        dw 0
  21. r1        dw 0
  22. c1        dw 0
  23. frame_type    db 0
  24. frame_color    db 8Fh
  25. last_col    dw 79
  26. last_row    dw 24
  27. move_box    db ' Use ,,, to move box ',0
  28. scroll_box    db ' Use ,,, to scroll box ',0
  29.  
  30. .code
  31. textdemo    proc
  32.     call    crtinfo
  33.     dec    al
  34.     mov    byte ptr last_row,al
  35.     dec    ch
  36.     mov    byte ptr last_col,ch
  37.  
  38.     mov    frame_type,0
  39.     or    frame_color,80h
  40.     mov    r0,5
  41.     mov    c0,5
  42.     mov    r1,20
  43.     mov    c1,50
  44.     mov    bx,0001h    ; copy page 0 to page 1
  45.     call    tcopy
  46.     call    usetpage
  47. td01:    lea    bx,r0
  48.     call    wsize
  49.     xor    dx,dx
  50.     call    dosalloc
  51.     mov    wseg,ax        ; save segment address
  52.     mov    es,ax
  53.     xor    di,di        ; ES:[DI] points to buffer
  54.     call    wsave
  55.     mov    al,'≡'
  56.     mov    ah,7
  57.     call    wfill
  58.     mov    ax,word ptr frame_type
  59.     call    wframe
  60.     lea    si,move_box
  61.     mov    dh,byte ptr r0
  62.     inc    dh
  63.     mov    dl,byte ptr c0
  64.     inc    dl
  65.     mov    ah,14
  66.     call    tprint
  67.     mov    bx,0100h
  68.     call    tcopy
  69.     call    getkey
  70.     shr    ah,1
  71.     jnc    td02
  72.     jmp    extended
  73. td02:    cmp    al,27
  74.     je    td99
  75.     cmp    al,13
  76.     jne    td01
  77.  
  78. ; ENTER was pressed
  79.     xor    bl,bl
  80.     call    usetpage
  81.     and    frame_color,0Fh
  82.     mov    frame_type,0FFh
  83.  
  84.     lea    bx,r0
  85.     mov    es,wseg
  86.     xor    di,di
  87.     call    wrestore
  88.     mov    ah,49h
  89.     int    21h
  90.     mov    ax,word ptr frame_type
  91.     call    wframe
  92.     lea    si,scroll_box
  93.     mov    ah,14
  94.     mov    dh,byte ptr r0
  95.     inc    dh
  96.     mov    dl,byte ptr c0
  97.     inc    dl
  98.     call    tprint
  99. td11:    call    getkey
  100.     cmp    ax,13
  101.     je    td99
  102.     shr    ah,1
  103.     jc    td110
  104.     jmp    td11
  105.  
  106. td99:    ret
  107.  
  108. textdemo    endp
  109.  
  110. td110:    cmp    al,72
  111.     je    up2
  112.     cmp    al,80
  113.     je    down2
  114.     sub    al,76
  115.     cmp    al,1
  116.     je    td12
  117.     cmp    al,0FFH
  118.     jne    td11
  119. td12:    cbw
  120.     mov    cx,ax
  121.     neg    cx
  122.     call    ansicolor
  123.     lea    bx,r0
  124.     call    hscroll
  125.     jmp    td11
  126. up2:    mov    cx,1
  127.     jmp    short scroll_updown
  128. down2:    mov    cx,-1
  129. scroll_updown:
  130.     call    ansicolor
  131.     lea    bx,r0
  132.     call    vscroll
  133.     jmp    td11
  134.  
  135. extended:
  136.     lea    bx,r0
  137.     mov    es,wseg
  138.     xor    di,di
  139.     call    wrestore
  140.     push    ax
  141.     mov    ah,49h
  142.     int    21h
  143.     pop    ax
  144.     cmp    al,72
  145.     je    up
  146.     cmp    al,80
  147.     je    down
  148.     cmp    al,75
  149.     je    left
  150.     cmp    al,77
  151.     je    right
  152. e9:    jmp    td01
  153.  
  154. up:    dec    r0
  155.     js    no_up
  156.     dec    r1
  157.     jmp    e9
  158. no_up:    inc    r0
  159.     jmp    e9
  160.  
  161. down:    inc    r1
  162.     mov    ax,r1
  163.     cmp    ax,last_row
  164.     ja    no_down
  165.     inc    r0
  166.     jmp    e9
  167. no_down:dec    r1
  168.     jmp    e9
  169.  
  170. left:    dec    c0
  171.     js    no_left
  172.     dec    c1
  173.     jmp    e9
  174. no_left:inc    c0
  175.     jmp    e9
  176.  
  177. right:    inc    c1
  178.     mov    ax,c1
  179.     cmp    ax,last_col
  180.     ja    no_right
  181.     inc    c0
  182.     jmp    e9
  183. no_right:
  184.     dec    c1
  185.     jmp    e9
  186.  
  187.     end
  188.